<template>
	<view>
		<uni-popup ref="popup" type="center" border-radius="10px 10px 10px 10px" @maskClick="handleConfigClick(false)">
			<view class="prompt_box">
				<view class="tit">{{msg.title}}</view>
				<image src="@/pages/groupbuy/static/red_points.png"></image>

				<view class="msg">
					<text class="tishi">本次操作可兑换 {{red_points}} 拼团积分</text>
					<text>
						，请确认 是否将“发团权益卡” 兑换为 “拼团积分”？ 此操作不可撤回，确定请点击确认兑换。
					</text>
				</view>
				<view class="btns">
					<view class="btn1" @click="handleConfigClick(false)">{{msg.cancel}}</view>
					<view class="btn2" @click="handleConfigClick(true)">{{msg.config}}</view>
				</view>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	export default {
		props: ['red_points', 'cardId'],
		data() {
			return {
				msg: {
					title: '兑换积分',
					content: '',
					cancel: '取消操作',
					config: '确认兑换'
				},
			}
		},
		methods: {
			open() {
				setTimeout(() => {
					this.$refs.popup.open()
				}, 1)
			},
			close() {
				this.$refs.popup.close();
			},
			handleConfigClick(e) {
				console.log('eeee', e, this.cardId);
				if (e == true) {
					// 显示加载提示
					uni.showLoading({
						title: '正在兑换...',
						mask: true // 建议设置为 true，防止用户在加载时进行其他操作
					});
					this.$axios('RedPoints/exc', 'POST', 'pt', {
						id: this.cardId
					}).then(res => {
						if (res.data.code == 200) {
							uni.showToast({
								title: '兑换成功',
								icon: 'success'
							});
							this.$emit('config', e)
							this.close()
						}
					})

				} else {
					// this.$emit('config', e)
					this.close()
				}

			}
		}
	}
</script>

<style lang="scss">
	.prompt_box {
		width: 574rpx;
		height: 556rpx;
		background: #FFFFFF;
		border-radius: 16rpx;
		padding: 30rpx;
		display: flex;
		flex-direction: column;
		justify-content: space-around;
		align-items: center;

		.tit {
			margin-bottom: 20rpx;
		}

		image {
			width: 390rpx;
			height: 120rpx;

		}

		.tit {
			color: #13001E;
			font-size: 32rpx;
			font-weight: bold;
		}

		.msg {
			color: #5B5B5B;
			font-size: 24rpx;
			text-align: center;
			margin: 20rpx 0;

			.tishi {
				color: #9A1FE8;
				font-weight: 700;
				text-decoration: underline;
				/* 下划线样式 */
				text-decoration-color: #9A1FE8;
				/* 紫色（RGB值） */
			}
		}

		.btns {
			width: 100%;
			// background-color: pink;
			display: flex;
			// align-items:;
			justify-content: space-between;
			margin-top: 20rpx;

			view {
				width: 248rpx;
				height: 86rpx;
				border-radius: 16rpx;
				font-size: 28rpx;
				line-height: 86rpx;
				text-align: center;
			}

			.btn1 {
				background: #f0defc;
				color: #9A1FE8;
			}

			.btn2 {
				color: #FFFFFF;
				background: #9A1FE8;
			}
		}
	}
</style>